package handlers

import (
	"image"
)

type WriteLine struct {
	X       int
	Y       int
	Color   string
	Width   int
	Height  int
	OffsetX int
	OffsetY int
}

func (w *WriteLine) Process(img *image.RGBA) (*image.RGBA, error) {
	if w.Color == "" {
		return img, nil
	}
	beginWidth, beginHeight := w.X+w.OffsetX, w.Y+w.OffsetY
	endWidth, endHeight := beginWidth+w.Width, w.Height+beginHeight
	color := RGBAColor(w.Color)

	for x := beginWidth; x <= endWidth; x++ {
		for y := beginHeight; y <= endHeight; y++ {
			img.Set(x, y, color)
		}
	}

	return img, nil
}
